<template>
  <div class="usercontiner beautifulScroll" v-if="!recordshow">
    <!-- 头像栏目完成 -->
    <div class="usermainbox" @click="goinfo">
      <div class="userimg">
        <img :src="`${base + studentdata.headPortraitUrl}`" alt="" />
      </div>
      <div class="userdesbox">
        <div class="username">{{ studentdata.studentName }}</div>
        <div class="userdes">查看并编辑个人资料</div>
      </div>
      <div class="userment"><van-icon name="arrow" /></div>
    </div>
    <!-- 学习记录栏目 -->
    <div class="stubox">
      <div class="stuimgitem" @click="(record = 1), (recordshow = true)">
        <img src="@/assets/images/tp.png" alt="" />
      </div>
      <div class="stuimgitem" @click="(record = 2), (recordshow = true)">
        <img src="@/assets/images/bl.png" alt="" />
      </div>
    </div>
    <!-- 菜单栏目 -->
    <div class="usermentbox">
      <div class="usermentitem">
        <div class="usermenticon">
          <img src="@/assets/images/Star 1.png" alt="" />
        </div>
        <div class="usermentdes" @click="gofavorite">我的收藏夹</div>
        <div class="usermentrght"><van-icon name="arrow" /></div>
      </div>
      <div class="usermentitem">
        <div class="usermenticon usermenticon2">
          <img src="@/assets/images/Rectangle.png" alt="" />
        </div>
        <div class="usermentdes" @click="gobook">我的书签</div>
        <div class="usermentrght"><van-icon name="arrow" /></div>
      </div>
      <div class="usermentitem">
        <div class="usermenticon">
          <img src="@/assets/images/xm.png" alt="" />
        </div>
        <div class="usermentdes" @click="gopsw">修改密码</div>
        <div class="usermentrght"><van-icon name="arrow" /></div>
      </div>
      <div class="usermentitem">
        <div class="usermenticon">
          <img src="@/assets/images/yxa.png" alt="" />
        </div>
        <div class="usermentdes" @click="goyj">意见反馈</div>
        <div class="usermentrght"><van-icon name="arrow" /></div>
      </div>
      <div class="usermentitem" @click="goupdate">
        <div class="usermenticon usermenticon3">
          <img src="@/assets/images/bb.png" alt="" />
        </div>
        <div class="usermentdes">版本更新</div>
        <div class="usermentrght"><van-icon name="arrow" /></div>
      </div>
    </div>
    <!-- 退出登录 -->
    <div class="userloding" @click="logoutfn">退出登录</div>
    <!-- 底部tab -->
    <Tabbar :active="3" />
  </div>
  <!-- 学习记录列表 -->
  <Record :record="record" v-if="recordshow" @goback="goback" />
</template>

<script lang="ts" setup>
  import Tabbar from '../tabbar/tabbar.vue';
  import { reactive, ref, onMounted, onBeforeUnmount } from 'vue';
  import { storeToRefs } from 'pinia';
  import { useUserStore } from '@/store';
  import { Pagination } from '@/types/global';
  import { showSuccessToast, showFailToast } from 'vant';
  const userStore = useUserStore();
  const userdata = storeToRefs(userStore);
  const studentId = ref(userdata.studentId.value);
  const studentdata = ref(userdata);
  console.log('目前的用户数据', studentdata.value);
  const base = ref((window as any).config.VUE_APP_IMG_API);
  import { useRouter, useRoute } from 'vue-router';
  import Record from './record.vue';
  const router = useRouter();
  import useUser from '@/hooks/user';
  const route = useRoute();
  const { logout } = useUser();
  const goupdate = () => {
    showSuccessToast('已是最新版');
  };
  const recordshow = ref(false);
  const record = ref(1);
  const goback = () => {
    recordshow.value = false;
  };
  const gobook = () => {
    router.push({
      name: 'bookMark',
    });
  };
  const gofavorite = () => {
    router.push({
      name: 'favorite',
    });
  };
  const gopsw = () => {
    router.push({
      name: 'password',
    });
  };
  const goyj = () => {
    router.push({
      name: 'feedback',
    });
  };
  const goinfo = () => {
    router.push({
      name: 'userinfo',
    });
  };
  const logoutfn = () => {
    logout();
  };
</script>

<style scoped>
  .usercontiner {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background: linear-gradient(180deg, #b9c7d6 0%, #fff 25%);
    position: absolute;
    top: 0px;
    left: 0px;
    padding: 20px 47px;
  }
  .usermainbox {
    display: flex;
    margin: 20px auto;
    margin-top: 80px;
    align-items: center;
  }
  .userimg {
    width: 139px;
    height: 139px;
    border-radius: 50%;
    overflow: hidden;
  }
  .userimg img {
    width: 139px;
    height: 139px;
  }
  .userdesbox {
    display: flex;
    flex-direction: column;
    margin-left: 20px;
  }
  .username {
    font-size: 40px;
    color: #000;
    width: 450px;
    white-space: nowrap; /* 禁止换行 */
    overflow: hidden; /* 超出隐藏 */
    text-overflow: ellipsis; /* 显示省略号 */
  }
  .userdes {
    font-size: 32px;
    color: #666666;
    margin: 10px 0;
  }
  .userment {
    font-size: 40px;
    color: #666666;
  }
  .stubox {
    display: flex;
    width: 100%;
    justify-content: space-between;
  }
  .stuimgitem {
    width: 320px;
    height: 125px;
    overflow: hidden;
  }
  .stuimgitem img {
    width: 320px;
    height: 125px;
    overflow: hidden;
  }
  .usermentbox {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 10px;
  }
  .usermentitem {
    height: 102px;
    width: 100%;
    display: flex;
  }
  .usermenticon {
    width: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  .usermentdes {
    width: 592px;
    border-radius: 0px 0px 0px 0px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 28px;
    color: #666666;
    display: flex;
    align-items: center;
  }
  .usermenticon img {
    width: 39px;
    height: 37px;
  }
  .usermenticon2 img {
    width: 28px;
    height: 36px;
  }
  .usermenticon3 img {
    width: 38px;
    height: 38px;
  }
  .usermentrght {
    display: flex;
    align-items: center;
    font-size: 32px;
    color: #666666;
  }
  .userloding {
    font-size: 32px;
    color: #fff;
    width: 662px;
    height: 90px;
    background: #7b92ac;
    box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
    border-radius: 102px 102px 102px 102px;
    text-align: center;
    line-height: 90px;
    margin-top: 40px;
  }
</style>
